package com.drk.skifree;



import org.anddev.andengine.opengl.texture.region.TextureRegion;
import org.anddev.andengine.util.pool.GenericPool;



public class ObjectPool extends GenericPool<ObjectSprite>  {
	private TextureRegion mTextureRegion;
	
	public ObjectPool(TextureRegion tr)
	{
		this.mTextureRegion = tr;
	}
	/* Called when a Bullet is required but there isn't one in the pool
	 */
	 @Override
	 protected ObjectSprite onAllocatePoolItem() {
	  return new ObjectSprite(mTextureRegion);
	 }

	 /**
	  * Called when a Bullet is sent to the pool
	 */
	 @Override
	 protected void onHandleRecycleItem(final ObjectSprite pBullet) {
	  pBullet.setIgnoreUpdate(true);
	  pBullet.setVisible(false);
	 }

	 /**
	  * Called just before a Bullet is returned to the caller, this is where you write your initialize code
	  * i.e. set location, rotation, etc.
	 */
	 @Override
	 protected void onHandleObtainItem(final ObjectSprite pBullet) {
	  pBullet.reset();
	  pBullet.setIgnoreUpdate(false);
	  pBullet.setVisible(true);
	 }
	}


